<template>
  <div>
    <excel-importer ref="importer" :title="'导入外部订单'" :tip-msg="tips" :download-template-url="downloadTemplate" :upload-url="upload" @confirm="e => $emit('confirm', e)" >
    </excel-importer>
  </div>
</template>

<script>
import ExcelImporter from '@/components/ExcelImporter'
import { request } from '@/utils/request'
export default {
  name: 'SaleOutImporter',
  components: { ExcelImporter },
  data() {
    return {
      selectedPlatform: undefined,
      platformOptions: [
        { value: 'pdd', label: '拼多多' },
        { value: 'taobao', label: '淘宝' },
        { value: 'douyin', label: '抖音' },
        { value: 'xiaohongshu', label: '小红书' }
      ],
      tips: '外部的商品编号必须与系统内编号相同，如不同会过滤，外部订单号可以重复'
    }
  },
  computed: {
  },
  methods: {
    openDialog() {
      this.$refs.importer.openDialog()
    },
    closeDialog() {
      this.$refs.importer.closeDialog()
    },
    downloadTemplate() {
      return request({
        url: '/sale/out/sheet/import/template',
        region: 'cloud-api',
        method: 'get',
        responseType: 'blob'
      })
    },
    upload(params) {
      this.$set(params, 'scId', this.scId)
      return request({
        url: '/sale/out/sheet/import',
        region: 'cloud-api',
        method: 'post',
        dataType: 'file',
        data: params
      })
    }
  }
}
</script>

<style lang="less">
</style>
